package com.chatplus.application.web.common;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.Instant;

@SuppressWarnings("WeakerAccess")
public abstract class AbstractModel implements Serializable {
    private static final long serialVersionUID = 1755460393912075723L;

    public static int sortCreatedAtDesc(AbstractModel item, AbstractModel next) {
        if (item.getCreatedAt().equals(next.getCreatedAt())) {
            return 0;
        } else if (item.getCreatedAt().isBefore(next.getCreatedAt())) {
            return 1;
        } else {
            return -1;
        }
    }

    @NotNull
    private Instant createdAt;
    @NotNull
    private Instant updatedAt;

    private Instant deletedAt;

    public Instant getDeletedAt() {
        return deletedAt;
    }

    public void setDeletedAt(Instant deletedAt) {
        this.deletedAt = deletedAt;
    }

    public Instant getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Instant createdAt) {
        this.createdAt = createdAt;
    }

    public Instant getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Instant updatedAt) {
        this.updatedAt = updatedAt;
    }
}
